<?php
/**
 * Profiles View for Congregation Component
 * 
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4
 * @license		GNU/GPL
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view' );

/**
 * Profiles View
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class CongregationViewBirthdays extends CongregationView
{
	/**
	 * Sharings view display method
	 * @return void
	 **/

	 
	function display($tpl = null)
	{
	
		global $mainframe;
		$document	=& JFactory::getDocument();
		$params =& $mainframe->getParams();
		$feedEmail = (@$mainframe->getCfg('feed_email')) ? $mainframe->getCfg('feed_email') : 'author';
		$siteEmail = $mainframe->getCfg('mailfrom');
		$document->link = JRoute::_('index.php?option=com_congregation&controller=profile&task=birthdays');

		// Get some data from the model
		JRequest::setVar('limit', $mainframe->getCfg('feed_limit'));
		$model =& $this->getModel('profile');

		
		var_dump($this->getModel());
		//$rows 		= & $model->getBirthdayList();
		
		$lastday = 0;
		var_dump($rows);
		exit;
		foreach ( $rows as $row )
		{
			
			// strip html from feed item title
			$title = JText::_("Compleanno di oggi");
			$title = html_entity_decode( $title );

			// url link to article
			$link = JRoute::_('index.php');

			// strip html from feed item description text
			$description	= 
			$author			= $row->created_by_alias ? $row->created_by_alias : $row->author;
						
			// load individual item creator class
			$item = new JFeedItem();
			$item->title 		= $title;
			$item->link 		= $link;
			$item->description 	= $description;
			$item->date			= $row->created;
			$item->category   	= 'frontpage';
			$item->author		= $author;
			if ($feedEmail == 'site') {
				$item->authorEmail = $siteEmail;
			}
			else {
				$item->authorEmail = $row->author_email;
			}
			// loads item info into rss array
			$document->addItem( $item );
		}
	}
	

}
